@extends('app.base')

@section('page_title')
  发布作品
@endsection

@section('page_header')
  <link rel="stylesheet" href="/bower_components/AdminLTE/bootstrap/css/bootstrap.min.css">
  <link rel="stylesheet" href="/bower_components/form.validation/dist/css/formValidation.min.css">
  <link rel="stylesheet" type="text/css" href="/bower_components/fancybox/dist/jquery.fancybox.min.css">
@endsection

@section('content')
  <div class="top-header">
    <h3>发布作品</h3>
    <span class="go-back"><i class="fa fa-angle-left"></i></span>
  </div>
  <div class="content">
    <div class="post-form">
      <form method="post">
        {{ csrf_field() }}
        <div class="form-group">
          <label for="author">作者</label>
          <input class="form-control" id="author" name="author" value="{{ request()->app_user->name }}" readonly>
        </div>
        <div class="form-group">
          <label for="title">标题</label>
          <input class="form-control" id="title" name="title" value="">
        </div>
        <div class="form-group">
          <label for="content">正文</label><br />
          <textarea id="content" name="content" rows=5></textarea>
        </div>
        <button class="btn full-width-btn" type="submit">发表</button>
      </form>
    </div>
  </div>
@endsection

@section('page_script')
  <script src="/bower_components/form.validation/dist/js/formValidation.min.js"></script>
  <script src="/bower_components/form.validation/dist/js/framework/bootstrap.min.js"></script>
  <script src="/bower_components/tinymce/tinymce.hack.min.js"></script>
  <script src="/js/tinymce.zh_CN.js"></script>
  <script src="/bower_components/fancybox/dist/jquery.fancybox.min.js"></script>
  <script>
$(function(){
  tinymce.init({
    selector: 'textarea',
    images_upload_url: '/api/tinymce/upload',
    menubar: false,
    plugins: [
      'advlist autolink lists link image charmap print preview anchor textcolor',
      'searchreplace visualblocks code fullscreen',
      'insertdatetime media table contextmenu paste code autosave help'
    ],
    toolbar: 'insert | undo redo |  styleselect | bold italic backcolor fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | code fullscreen',
  })

  @isset ($success)
    $.fancybox.open('<div class="message"><h2>提示</h2><p>发表成功，请耐心等待审核</p></div>');
  @endisset

  $('form').formValidation({
    framework: 'bootstrap',
    fields: {
      title: {
        validators: {
          notEmpty: {
            message: '请输入标题'
          }
        }
      }
    }
  })
})
  </script>
@endsection
